var res = [];
var app = angular.module("app", []);
app.controller("goodsListController", function($scope, $http) {
	$scope.initView = function() {
		$http({
			method: 'post',
			url: apiRoot,
			data: {
				action: 'Trade.getCateGoods',
				cid:cid,
				page:cur_page,
			}
		}).then(function success(response){
			res.push(response.data.data); 
			$scope.goods = res;
		});
	}
	$scope.open = function(uid,type,id){
		console.log(uid+"###"+type+"#####"+id);
		openPage("goods_detail.html",{gUid:uid,type:type,gId:id});
	}
})

var cur_page=1,cid;
document.addEventListener("plusready", function() {
	var ws = plus.webview.currentWebview();
	appElement = document.querySelector('[ng-controller=goodsListController]');
	$scope = angular.element(appElement).scope();
	$scope.name = ws.name;
	cid = ws.type;
	$scope.initView();
	$scope.$apply();
})